﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RzCorportativo.Views
{
    public partial class FormacaoVaga : System.Web.UI.UserControl
    {
        private Lib.Vaga CurrentVaga { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
                return;
            this.NomeCurso.Attributes.Add("url", this.ResolveUrl("~/Views/Cadastros/Curriculo.aspx/ListarCursos"));
            if (this.CurrentVaga == null)
                return;
            List<Lib.Curso> lista = this.CurrentVaga.ListarCursos();
            foreach (var item in lista)
            {
                var row = new System.Web.UI.HtmlControls.HtmlTableRow();
                row.Cells.Add(new System.Web.UI.HtmlControls.HtmlTableCell()
                {
                    InnerText = item.Nome
                });
                row.Cells.Add(new System.Web.UI.HtmlControls.HtmlTableCell()
                {
                    InnerHtml = "<input type='button' id='btnRemove'" + item.CursoId.ToString() +
                         " onclick='RemoveFormacao(" + item.CursoId.ToString() + ", " + CurrentVaga.VagaId.ToString() + ", this)' class='btn btn-danger' value='remover'/>"
                });
                this.gridFormacao.Rows.Add(row);
            }
        }

        internal void LoadModel(Lib.Vaga vaga)
        {
            this.CurrentVaga = vaga;
        }
    }
}
